package com.ludaxu.google.fragment;

import java.util.List;

import android.view.View;

import com.ludaxu.google.adapter.ListBaseAdapter;
import com.ludaxu.google.domain.AppInfo;
import com.ludaxu.google.protocol.GameProtocol;
import com.ludaxu.google.tools.UiUtils;
import com.ludaxu.google.view.BaseListView;
import com.ludaxu.google.view.LoadingPage.loadResult;

public class GameFragment extends BaseFragment {

	private List<AppInfo> datas;

	/**
	 * 加载成功界面
	 */
	@Override
	public View createSuccessView() {
		BaseListView listView = new BaseListView(UiUtils.getContext());
		listView.setAdapter(new ListBaseAdapter(datas) {

			@Override
			protected List<AppInfo> onLoad() {
				GameProtocol protocol = new GameProtocol();
				List<AppInfo> load = protocol.load(datas.size());//
				datas.addAll(load);
				return load;
			}

		});
		return listView;
	}

	/**
	 * 请求服务器,加载数据
	 */
	@Override
	public loadResult load() {
		GameProtocol protocol = new GameProtocol();
		datas = protocol.load(0);
		return checkData(datas);
	}

}
